package com.avecsys.quotemanager.ui.components;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import com.icesoft.faces.context.effects.JavascriptContext;

/**
 * @author Sam Sundar K
 * @param <T>
 */
public class LookUpDialog<T> implements Serializable
{
	private String dialogId;

	private List<T> dataList = new ArrayList<T>();

	public LookUpDialog(String dialogId)
	{
		super();
		this.dialogId = dialogId;
	}

	public LookUpDialog(String dialogId, List<T> dataList)
	{
		super();
		this.dialogId = dialogId;
		this.dataList = dataList;
	}

	/**
	 * @return the dataList
	 */
	public List<T> getDataList()
	{
		return dataList;
	}

	/**
	 * @return the dialogId
	 */
	public String getDialogId()
	{
		return dialogId;
	}

	/**
	 * @param dataList the dataList to set
	 */
	public void setDataList(List<T> dataList)
	{
		this.dataList = dataList;
	}

	/**
	 * @param dialogId the dialogId to set
	 */
	public void setDialogId(String dialogId)
	{
		this.dialogId = dialogId;
	}

	public void showDialog()
	{
		JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), getDialogId()
				+ ".show();");
	}

	public void hideDialog(ActionEvent actionEvent)
	{
		JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), getDialogId()
				+ ".hide();");
	}

	public void hideDialog()
	{
		JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), getDialogId()
				+ ".hide();");
	}

}
